package com.baobao.excel.easypoi.bean;

import cn.afterturn.easypoi.excel.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.util.Date;
import java.util.List;

/**
 * @author baobao
 * @create 2021-02-02 16:53
 * @description
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ExcelTarget("user")
public class User {
    public interface VerifyGroup{}

    @Excel(name = "编号", orderNum = "0", needMerge = true)
    @NotNull(message = "编号不能为空")
    @Min(value = 0, message = "编号不能小于0")
    private Long id;

    @Excel(name = "姓名", orderNum = "1", isHyperlink = true, needMerge = true)
    @Pattern(regexp = "[\u4E00-\u9FA5]*", message = "姓名必须是中文", groups = VerifyGroup.class)
    private String name;

    @Excel(name = "年龄", orderNum = "2", needMerge = true)
    private Integer age;

    @Excel(name = "生日", orderNum = "3", width = 35, format = "yyyy-MM-dd HH:mm:ss", needMerge = true)
    private Date birth;

    @Excel(name = "状态", replace = {"锁定_0","激活_1"}, needMerge = true)
    private Integer status;

    /**标识一对一关系*/
    @ExcelEntity(name = "身份信息", show = true)
    private IdCard idCard;

    @ExcelCollection(name = "订单列表", orderNum = "7")
    private List<Order> orderList;

    @ExcelIgnore
    private String url;
}
